<template>
    <div class="page">
        <ul class="team-list">
            <li v-for="item in items" @click="gotoTeamAdmin(item.team_id)">
                <a>
                    <div class="titlebar">
                        <h2>{{item.team_name}}</h2>
                        <span class="arrow"></span>
                    </div>
                    <div class="content">
                        <span class="logo"></span>
                        <p class="num"><em>{{item.members_count}}</em>人</p>
                    </div>
                </a>
            </li>
        </ul>
    </div>
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import $ from 'zepto'
    import clientInfo from 'gapi/clientInfo'
    import * as util from 'js/util.js'
    import cache from 'gapi/cache'
    import widget from 'gapi/widget'

    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                items: [],
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
              this.projectId = util.getUrddataString('pId')
              this.teamId = util.getUrddataString('tId')
              this.userId = util.getUrddataString('uId')
              this.groupId = util.getUrddataString('gId')
              //获取团队list
              this.getTeamList()
            },
            //
            gotoTeamAdmin(teamId){
              let encodeStr = encodeURIComponent(`teamIdForProject=${this.teamId}&teamId=${teamId}&projectId=${this.projectId}&source=addTeamMember&groupId=${this.groupId}`)
              // alert(encodeStr);
              location.href = `dmsaas://TeamSelectPeople?urdData=${encodeStr}`
            },
            getTeamList(){
              util.ajax({
                    url:'/team/list/detail',
                    type:'GET',
                    data:{
                      team_id: this.teamId,
                      project_id : this.projectId,
                      // offset:
                      // rows:
                    },
                    timeout:10000,
                    beforeSend: () => {

                    },
                    success:(result) => {
                      console.log(result)
                        // alert(JSON.stringify(result))
                        if(result.errno == 0){
                          this.items = result.data
                        }
                    },
                    error: (xhr, status) => {
                        // error
                        console.log(xhr)
                    },
                    complete: () => {

                    },
                    noNetwork: () => {
                        // 无网络的回调
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            }
        },
        created(){
          this.init();
        }

    }


</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/team.css"></style>
